<!DOCTYPE html>
<html>
<head>
	<title>Number format</title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
	<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
	<link rel="stylesheet" type="text/css" href="../../../codebase/fonts/font_roboto/roboto.css"/>
	<link rel="stylesheet" type="text/css" href="../../../codebase/dhtmlx.css"/>
	<script src="../../../codebase/dhtmlx.js"></script>
	<script>
		var myForm, myForm2;
		function doOnLoad() {
			// init from json
			formData = [
				{type: "settings", position: "label-left", labelWidth: 250, inputWidth: 120},
				{type: "fieldset", label: "Number Formats", inputWidth: "auto", list:[
					{type: "input", name: "t1", label: "Format: 0,000.00", value: "1234567.8987", numberFormat: "0,000.00"},
					{type: "input", name: "t2", label: "Format: @ 0,00 (before_change=false)", value: "123456.78", numberFormat: ["@ 0,00",":"]},
					{type: "input", name: "t3", label: "Format: $ 0.00", value: "125750.99", numberFormat: ["$ 0,000.00",",","."]},
					{type: "input", name: "t4", label: "Format: 0,000 Rub", value: "10250.45", numberFormat: ["0,000 Rub","'"]},
					{type: "input", name: "t5", label: "Format: 0,000.00 Kr (set with script)", value: "99570.45"}
				]}
			];
			myForm = new dhtmlXForm("myForm", formData);
			myForm.setNumberFormat("t5","0,000.00 Kr","'",",");
			myForm.attachEvent("onChange", function(){
				// console.log("onChange",arguments)
			});
			myForm.attachEvent("onBeforeChange", function(name){
				// console.log("onBeforeChange",arguments)
				return (name != "t2");
			});
			// xml
			myForm2 = new dhtmlXForm("myForm2");
			myForm2.loadStruct("../common/dhxform_numberformat.xml", function(){
				myForm2.setNumberFormat("t5","0,000.00 Kr","'",",");
			});
			
		}
		
	</script>
</head>
<body onload="doOnLoad();">
	<table border="0" cellspacing="2" cellpadding="2">
		<tr>
			<td align="left" valign="top"><div id="myForm"></div></td>
			<td align="left" valign="top"><div id="myForm2" style="margin-left: 30px;"></div></td>
		</tr>
	</table>
	<div style="padding-top: 10px;">
		<b>JSON</b> { numberFormat: "format" } or { numberFormat: ["format", "group_sep", "dec_sep"] }<br>
		<b>XML</b> &lt; numberFormat="format" groupSep="group_sep" decSep="dec_sep" &gt;<br>
		<br>
		"format" required, "group_sep" and "dec_sep" optional, "," and "." are defaults
	</div>
</body>
</html>